import javafx.scene.media.AudioClip;
import video.MyFrame;
import video.Video;

import java.io.File;

public class Draw {

    public static void main(String[] args) {
        String mp4FilePath = Constants.MP4_FILE_PATH;
        String mp3Path = Constants.MP3_PATH;
        // 渲染视频
        draw(mp4FilePath);
        // 窗口播放
        play(mp4FilePath, mp3Path);
    }

    private static void play(String mp4FilePath, String mp3Path) {
        String videoPath = mp4FilePath.substring(0, mp4FilePath.lastIndexOf(".")) + ".video";
        Video video = new Video(videoPath);
        new MyFrame(video,
                new AudioClip(new File(mp3Path).toURI().toString()));//该路径是播放音乐时的背景音乐的路径
    }

    private static void draw(String filepath) {
        /**
         * 输入生成的video文件的路径或者个视频的路径
         * video是已完成渲染的视频，可立即启动
         * 其它视频需生成video文件后可启动
         */
        Video video = new Video(new File(filepath));
        video.save(filepath.substring(0, filepath.lastIndexOf(".")));
    }
}